from django import forms
from learing_logs.models import Topic,Entry,Blog

#表单

class TopicForm(forms.ModelForm):
    class Meta:
        model = Topic
        fields = ['text'] #表单的字段列表
        labels = {'text':'话题名:'} #表单生成标签 text 没有标签设置了空串

class EntryForm(forms.ModelForm):
    class Meta:
        model = Entry
        fields = ['text']
        labels = {'text':'新条目'}
        widgets = {'text':forms.Textarea(attrs={'cols':80})} #为字段设置指定的渲染组件 也就是html标签

class BlogForm(forms.ModelForm):
    class Meta:
        model = Blog
        fields = ['title','content','tags'] #表单要显示的字段
        labels = {'title':'标题','content':'','tags':'标签'}
        widgets = {'content':forms.Textarea(attrs={'cols':80})} #为表单字段知道渲染的部件

        